package components.ball;

import com.uqbar.vainilla.DeltaState;
import com.uqbar.vainilla.GameComponent;
import com.uqbar.vainilla.events.constants.Key;

public class StartBallState extends BallState {

	private GameComponent align;
	
	public StartBallState(NormalBall aBall, GameComponent alignTo) {
		super(aBall);
		this.align = alignTo;
	}

	@Override
	public void update(DeltaState deltaState) {

		this.getBall().alignTopTo(this.getAlign().getY() - this.getBall().getHeight());
		this.getBall().alignHorizontalCenterTo(this.getAlign().getX() + 20);
		
		if (deltaState.isKeyPressed(Key.SPACE)){
			this.newState(new PlayingBallState(this.getBall()));
		}
	}

	public void setAlign(GameComponent align) {
		this.align = align;
	}

	public GameComponent getAlign() {
		return align;
	}

}
